deliverInfoService.$inject = ['$http'];

function deliverInfoService($http) {
    return {
        addDeliverInfoByClient:addDeliverInfoByClient,
        getDeliverInfoByClient:getDeliverInfoByClient,
        updateDeliverInfo:updateDeliverInfo,
        deleteDeliverInfoById:deleteDeliverInfoById
    }

    function addDeliverInfoByClient(newdeliverInfo, callback) {
        $http.post("/cv4Backend/deliverInfo/addDeliverInfoByClient", newdeliverInfo).then(function(res) {
            callback(null, res.data);
        }).catch(err => console.log(err));
    }

    function getDeliverInfoByClient(cid, callback) {
        console.log('deliverinfo service come in');
        console.log(cid);
        $http.get("/cv4Backend/deliverInfo/getDeliverInfoByClient/"+cid).then(function(res) {
            console.log(res.data);
            callback(null, res.data);
        }).catch(err => console.log(err));
    }

    function updateDeliverInfo(deliverInfo, callback) {
        $http.post("/cv4Backend/deliverInfo/updateDeliverInfo", deliverInfo).then(function(res) {
            callback(null, res.data);
        }).catch(err => console.log(err));
    }

    function deleteDeliverInfoById(id, callback) {
        $http.get("/cv4Backend/deliverInfo/deleteDeliverInfoById/"+id).then(function(res) {
            console.log(res.data);
            callback(null, res.data);
        }).catch(err => console.log(err));
    }

}

module.exports = deliverInfoService;
